Valkyrie Code Conventions
--------------------------

1. Files
---------

All Valkyrie unit names begin with the letter "v". Units written around dominating classes are named by the pure class name (without the leading "T") prepended by the letter "v". All files should have the extention ".pas". 

Example filenames should NOT start with the letter "v".

Generaly units with classes should contain either a single class or a set of strongly related (ex. inherited) classes.

2. File Format
---------------

Files will start with a standard PASDOC/VALKYRIEDOC preamble. Licence information must also be included. First keyword ("unit") appears underneath them. The header may also contain : file-specific notes, to do items, etc.

All comments are made using the // keyword, unless it's a big (5+ lines) block of text, or a singleword note in the middle of code, when {} may be used.

3. Whitespace
--------------

All indentation is done with spaces. The indentation size is 2. 

Indentation:
-- "begin","case" keyword
-- "if","while","for" statements that dont fit in one line
-- chained "if","while","for" statements (unless followed by "begin")
-- type declaration -- In this case, the indentation begins 2 spaces after the type NAME.
-- "type", "var", "const", "uses" declarations that span more then one line will hev elements indented in a single collumn.

Linebreaks:
-- always after "begin","case"
-- always after the end of a statement*
-- always in a long procedure/function/method call if it exceedes 78 characters
-- may appear after "then" in a long "if" statement
-- may appear bofore "else" in a long "if" statement (can be indented so "else" is below "then")


Empty lines:
-- always between global blocks (procedures functions)
-- always after the keywords "implementation", "interface"
-- between declaration blocks in the declaration section
-- between each class declaration
-- between successive procedure/function/method implementations
-- between codeblocks if it increases readability and is logical

4. Capitalization
------------------

General rule -- despite Pascal being a case-insensitive language everything is meant to be written and used as if it were case-sensitive (always the same).

All keywords are to be written lowercase.

All variables and fields (except those whoose names aren't an english word), methods, types, procedures, and functions are to be capitalised for each word used, and should not contain the "_" character (function SomeWierdFunction(). 

Exception to this rule:
-- Method names starting with : set, get, is.
-- Enumeration elements starting with a common word.
-- variables, parameters etc, starting with a common word (especialy parameters prepended with "n").

Constant groups may be all uppercase and may contain the character "_".

* in some cases (like huge case tables), where the statement block would fit one line and is repetetive, this rule can/will be ommited.

5. Naming
----------

All types (also class types!) start with "T".

Long and descriptive variable, class, type names are almost always a must.

Every element name (except for pure counter variables) MUST be named after what it is used for.

Reusing a variable for a different role instead of declaring a new one is ONLY allowed in speed-critical parts of the code.

Constructors should always be named either Init, Load or Create (unless the need for more then one constructor with the same arguments arises).

Destructors should always be named Done.

The words "set", "is", "get" should be used as first parts of methods dealing with setting, getting and checking variables.


--------------------------------------------------------------------------------
Copyright (c) 2005  Kornel Kisielewicz.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.